﻿@using DotNet.Edu.Service
@model ExcerciseQuestion
@{
    Layout = null;
    int index = ViewBag.index;
    int prveIndex = index - 1;
    int nextIndex = index + 1;
    List<ExcerciseQuestion> exerciseQuestions = ViewBag.exerciseQuestions;
    StudentSession studentSession = ViewBag.studentSession;
    bool isFavorite = false;
    if (Model != null)
    {
        isFavorite = EduService.QuestionFavorite.IsFavorite(studentSession.StudentId, Model.Id, 2);
    }
}
@if (Model == null)
{
    <a class="button button-big button-fill button-danger">
        暂无练习题
    </a>
}
else
{
    <div style="background-color:white; border: 1px solid #e7e7e7;border-radius:4px;padding:4px;">
        @(index + 1)、(@Model.QuestTypeName)@Model.Name
    </div>
    <div class="list-block">
        <ul>
            @if (Model.QuestType == "1") //判断
            {
                @Html.Partial("_pd", Model)
            }
            else if (Model.QuestType == "2") //单选
            {
                @Html.Partial("_sx", Model)
            }
            else if (Model.QuestType == "3"|| Model.QuestType == "4") //多选
            {
                @Html.Partial("_mx", Model)
            }
        </ul>
    </div>
    <input id="correctAnswer" type="hidden" value="@Model.Answer" data-count="@exerciseQuestions.Count" data-current="@(index+1)" data-url="@Url.Action("CheckQuestion", new {questionId = Model.Id})" />

    if (!Model.UserSelected.HasValue && (Model.QuestType == "3" || Model.QuestType == "4"))
    {
        <a class="button button-big button-fill" id="btn_answer_submit">提交</a>
    }

    if (!Model.UserSelected.HasValue)//没有回答
    {
        <a class="button button-big button-fill" style="display:none;" id="answer_yes">回答正确</a>
        <a class="button button-big button-fill button-danger" style="display:none;" id="answer_no">正确答案：@Model.Answer</a>
    }
    else //已经回答
    {
        if (Model.UserResult)
        {
            <a class="button button-big button-fill" id="answer_yes">
                回答正确
            </a>
        }
        else
        {
            <a class="button button-big button-fill button-danger" id="answer_no">
                正确答案：@Model.Answer
            </a>
        }
    }
   
    <div class="bar bar-footer" id="cmdbar">
        <div class="row" style="height: 100%;">
            <div class="col-33">
                <a id="btn-favorite" class="button @Html.WriteValue(isFavorite, "button-fill")"
                   data-url="@Url.Action("FavoriteQuestion", new {questionId = Model.Id, favoriteType = 2})"
                   favorite="@Html.IIF(isFavorite, "1","0")">
                    <span class="fa fa-star"></span>
                    <span>@Html.IIF(isFavorite, "已收藏", "收藏")</span>
                </a>
            </div>
            <div class="col-33">
                @if (prveIndex > -1)
                {
                    <a id="btn-prve" class="button" data-url="@Url.Action("_Question", new {index = prveIndex})">上一题</a>
                }
                else
                {
                    <span>&nbsp;</span>
                }
            </div>
            <div class="col-33">
                @if (nextIndex < exerciseQuestions.Count)
                {
                    <a id="btn-next" class="button" data-url="@Url.Action("_Question", new {index = nextIndex})">下一题</a>
                }
            </div>
        </div>
    </div>
}
